//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.statistic;

import java.awt.BorderLayout;
import javax.swing.*;
import org.jpgolay.gui.fixed.*;
import org.jpgolay.gui.iconBar.IconBar;

public class StatisticsGUI extends JInternalFrame {

    public StatisticsGUI() {
        jContentPane = null;
        basicMenu = null;
        iconBar = null;
        jTabbedPane = null;
        salesPanel = null;
        buysPanel = null;
        accountsPanel = null;
        salesSearchBox = null;
        buysSearchBox = null;
        accountsSearchBox = null;
        salesTableViewer = null;
        buysTableViewer = null;
        accountsTableViewer = null;
        initialize();
    }

    private void initialize() {
        setJMenuBar(getBasicMenu());
        setFrameIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/statistics18x18.png")));
        setTitle("Statistiques");
        setSize(330, 200);
        setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getIconBar(), "North");
            jContentPane.add(getJTabbedPane(), "Center");
        }
        return jContentPane;
    }

    private BasicMenu getBasicMenu() {
        if (basicMenu == null) {
            basicMenu = new BasicMenu();
        }
        return basicMenu;
    }

    private IconBar getIconBar() {
        if (iconBar == null) {
            iconBar = new IconBar();
        }
        return iconBar;
    }

    private JTabbedPane getJTabbedPane() {
        if (jTabbedPane == null) {
            jTabbedPane = new JTabbedPane();
            jTabbedPane.addTab("Ventes", null, getSalesPanel(), null);
            jTabbedPane.addTab("Achats", null, getBuysPanel(), null);
            jTabbedPane.addTab("Compta", null, getAccountsPanel(), null);
        }
        return jTabbedPane;
    }

    private JPanel getSalesPanel() {
        if (salesPanel == null) {
            salesPanel = new JPanel();
            salesPanel.setLayout(new BorderLayout());
            salesPanel.add(getSalesSearchBox(), "North");
            salesPanel.add(getSalesTableViewer(), "Center");
        }
        return salesPanel;
    }

    private JPanel getBuysPanel() {
        if (buysPanel == null) {
            buysPanel = new JPanel();
            buysPanel.setLayout(new BorderLayout());
            buysPanel.add(getBuysSearchBox(), "North");
            buysPanel.add(getBuysTableViewer(), "Center");
        }
        return buysPanel;
    }

    private JPanel getAccountsPanel() {
        if (accountsPanel == null) {
            accountsPanel = new JPanel();
            accountsPanel.setLayout(new BorderLayout());
            accountsPanel.add(getAccountsSearchBox(), "North");
            accountsPanel.add(getAccountsTableViewer(), "Center");
        }
        return accountsPanel;
    }

    private SearchBox getSalesSearchBox() {
        if (salesSearchBox == null) {
            salesSearchBox = new SearchBox();
        }
        return salesSearchBox;
    }

    private SearchBox getBuysSearchBox() {
        if (buysSearchBox == null) {
            buysSearchBox = new SearchBox();
        }
        return buysSearchBox;
    }

    private SearchBox getAccountsSearchBox() {
        if (accountsSearchBox == null) {
            accountsSearchBox = new SearchBox();
        }
        return accountsSearchBox;
    }

    private TableViewer getSalesTableViewer() {
        if (salesTableViewer == null) {
            salesTableViewer = new TableViewer();
        }
        return salesTableViewer;
    }

    private TableViewer getBuysTableViewer() {
        if (buysTableViewer == null) {
            buysTableViewer = new TableViewer();
        }
        return buysTableViewer;
    }

    private TableViewer getAccountsTableViewer() {
        if (accountsTableViewer == null) {
            accountsTableViewer = new TableViewer();
        }
        return accountsTableViewer;
    }
    private JPanel jContentPane;
    private BasicMenu basicMenu;
    private IconBar iconBar;
    private JTabbedPane jTabbedPane;
    private JPanel salesPanel;
    private JPanel buysPanel;
    private JPanel accountsPanel;
    private SearchBox salesSearchBox;
    private SearchBox buysSearchBox;
    private SearchBox accountsSearchBox;
    private TableViewer salesTableViewer;
    private TableViewer buysTableViewer;
    private TableViewer accountsTableViewer;
}
